/* 
 * File:   Pixel.cpp
 * Author: mm021791
 * 
 * Created on 26 de septiembre de 2012, 13:12
 */

#include "Pixel.h"

using TP::Grafica::Pixel;

Pixel::Pixel() {
    _R = 0;
    _G = 0;
    _B = 0;
}

Pixel::Pixel(unsigned char pR, unsigned char pG, unsigned char pB){
    _R = pR;
    _G = pG;
    _B = pB;
}

Pixel::Pixel(const Pixel& orig) {
    _R = orig.getR();
    _G = orig.getG();
    _B = orig.getB();
}

Pixel::~Pixel() {}

unsigned char Pixel::getR() const{
    return _R;
}

unsigned char Pixel::getG() const{
    return _G;
}

unsigned char Pixel::getB() const {
    return _B;
}


namespace TP{ namespace Grafica { 

    istream& operator>> (istream& stream, Pixel& pixel){

        stream.read(reinterpret_cast < char * > (&pixel._B), sizeof(pixel._B));
        stream.read(reinterpret_cast < char * > (&pixel._G), sizeof(pixel._G));
        stream.read(reinterpret_cast < char * > (&pixel._R), sizeof(pixel._R));

        return stream;
    }
    
    ostream& operator<< (ostream& stream, const Pixel& pixel){

        stream.write(reinterpret_cast < const char * > (&pixel._B), sizeof(pixel._B));
        stream.write(reinterpret_cast < const char * > (&pixel._G), sizeof(pixel._G));
        stream.write(reinterpret_cast < const char * > (&pixel._R), sizeof(pixel._R));
        
        return stream;
    
    }
    
}}

